<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/7
 * Time: 20:11
 */
include "config.php";
if ($_SERVER["REQUEST_METHOD"]=="POST"){
    if (!empty($_REQUEST["uname"])){
        $goodcarSQL="SELECT *FROM bangg_net.`goodinfo` WHERE u_name=?";
        $stmt=$conn->prepare($goodcarSQL);
        $stmt->bind_param("s",$_REQUEST["uname"]);
        $stmt->execute();
        $result=$stmt->get_result();
//        print_r($result);
        $reslist=Array("status"=>0,"msg"=>"异常");
        if ($result->num_rows>=1){
            $reslist["status"]=1;
            $reslist["msg"]="查询成功";
            $dataList=Array();
            while ($rows=$result->fetch_assoc()){
                $goodlis=Array();
                $goodlis["pid"]=$rows["p_id"];
                $goodlis["title"]=$rows["p_title"];
                $goodlis["price"]=$rows["p_price"];
                $goodlis["num"]=$rows["p_num"];
                $goodlis["total"]=$rows["p_total"];
                $goodlis["img"]=$rows["p_img"];
                $reslist["goodlis"]=$goodlis;

                array_push($dataList,$goodlis);
            }
            $reslist["data"]= $dataList;
            print_r(json_encode($reslist));
        }else{
            print_r(json_encode(Array("status"=>0,"msg"=>"数据库无记录")));
        }
    }
}else{
    print_r(Array("status"=>0,"msg"=>"请使用post请求"));
}